<template>
	<view>
		<view class="tests">
			<textarea placeholder-class="textarea" 
			placeholder="你的宝贵意见是我们成长的动力！" v-model="params.content" maxlength="200">
			</textarea>
			<view class="testsabs">
				{{params.content.length}}/200
			</view>
		</view>
		<view class="upload">
			<imageUpload :upWith="160" :upHeight="160" :imgList="imageList" :maxCount="1" @change="imgFn"></imageUpload>
		</view>
		<view class="footerbtn">
			<view class="cont" @click="handleTj">
				<view class="btn">
					提交
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		feedAdd
	} from '@/common/http.api.js';
	export default {
		data() {
			return {
				value: '',
				imageList: [],
				params:{
					content:'',
					picture:""
				}
			};
		},
		methods:{
			imgFn(e){
				this.imageList = e
				this.params.picture = e[0].url
			},
			handleTj(){
				if(this.params.content == ''){
					uni.showToast({
						title:'请输入您的宝贵意见',
						icon:'none'
					})
					return
				}
				feedAdd(this.params).then(res=>{
					if(res.code == 200){
						uni.showToast({
							title:'已提交',
							icon:'none'
						})
						setTimeout(()=>{
							uni.navigateBack()
						},1000)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.tests {
		width: 710rpx;
		height: 280rpx;
		background: #FBFBFB;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 30rpx auto 0rpx;
		position: relative;

		.textarea {
			font-weight: 400;
			color: #D1D1D6;
		}

		textarea {
			width: 100%;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #000000;
			padding: 20rpx;
			box-sizing: border-box;
			height: 280rpx;
			border-radius: 10rpx;
		}

		.testsabs {
			position: absolute;
			bottom: 10rpx;
			right: 10rpx;
			font-size: 24rpx;
			color: #D1D1D6;
		}
	}

	.upload {
		width: 670rpx;
		padding: 20rpx;
		box-sizing: border-box;
		display: flex;

		.imglist {
			width: 140rpx;
			height: 140rpx;
			margin-right: 20rpx;
			position: relative;

			image {
				width: 140rpx;
				height: 140rpx;
				border-radius: 8rpx;
			}

			.icons {
				position: absolute;
				right: -16rpx;
				top: -16rpx;
			}

		}

		.add {
			display: flex;
			justify-content: center;
			align-items: center;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 24rpx;
			color: #979797;
			border: 1px solid #eee;
			width: 140rpx;
			height: 140rpx;
			border-radius: 8rpx;
			text-align: center;

			image {
				width: 48rpx;
				height: 48rpx;
			}
		}
	}

	.footerbtn {
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		position: fixed;
		bottom: 0%;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);

		.cont {
			display: flex;
			padding: 10rpx 20rpx;
			height: 120rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			align-items: center;
			justify-content: center;

			.btn {
				width: 670rpx;
				height: 100rpx;
				background: #000000;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				color: #FFFFFF;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #FFFFFF;
				line-height: 100rpx;
				text-align: center;
			}

			.absbtn {
				background: #808080;
			}
		}
	}
</style>